#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "vehicle.h"
#include "owner.h"
#include "sparepart.h"
#include "package.h"
#include "worker.h"
#include "user.h"
#include "repair.h"
#include "dbmanager.h"
#include <QStyle>
#include <QDesktopWidget>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::slotAddVehicle()
{
    Vehicle * vehicle = new Vehicle(0);
    vehicle->setGeometry(
        QStyle::alignedRect(
            Qt::LeftToRight,
            Qt::AlignCenter,
            vehicle->size(),
            qApp->desktop()->availableGeometry()
        ));
    vehicle->setWindowModality(Qt::ApplicationModal);
    vehicle->show();
}

void MainWindow::slotUpdateVehicle() {}
void MainWindow::slotDeleteVehicle() {}

void MainWindow::slotAddOwner()
{
    Owner * owner = new Owner(0);
    owner->setGeometry(
        QStyle::alignedRect(
            Qt::LeftToRight,
            Qt::AlignCenter,
            owner->size(),
            qApp->desktop()->availableGeometry()
        ));
    owner->setWindowModality(Qt::ApplicationModal);
    owner->show();
}

void MainWindow::slotUpdateOwner() {}
void MainWindow::slotDeleteOwner() {}

void MainWindow::slotAddSparePart()
{
    SparePart * sp = new SparePart(0);
    sp->setGeometry(
        QStyle::alignedRect(
            Qt::LeftToRight,
            Qt::AlignCenter,
            sp->size(),
            qApp->desktop()->availableGeometry()
        ));
    sp->setWindowModality(Qt::ApplicationModal);
    sp->show();
}

void MainWindow::slotUpdateSparePart() {}
void MainWindow::slotDeleteSparePart() {}

void MainWindow::slotAddRepair()
{
    Repair * repair = new Repair(0);
    repair->setGeometry(
        QStyle::alignedRect(
            Qt::LeftToRight,
            Qt::AlignCenter,
            repair->size(),
            qApp->desktop()->availableGeometry()
        ));
    repair->setWindowModality(Qt::ApplicationModal);
    repair->show();
}

void MainWindow::slotUpdateRepair() {}
void MainWindow::slotDeleteRepair() {}

void MainWindow::slotAddPackage()
{
    Package * package = new Package(0);
    package->setGeometry(
        QStyle::alignedRect(
            Qt::LeftToRight,
            Qt::AlignCenter,
            package->size(),
            qApp->desktop()->availableGeometry()
        ));
    package->setWindowModality(Qt::ApplicationModal);
    package->show();
}

void MainWindow::slotUpdatePackage() {}
void MainWindow::slotDeletePackage() {}

void MainWindow::slotAddWorker()
{
    Worker * worker = new Worker(0);
    worker->setGeometry(
        QStyle::alignedRect(
            Qt::LeftToRight,
            Qt::AlignCenter,
            worker->size(),
            qApp->desktop()->availableGeometry()
        ));
    worker->setWindowModality(Qt::ApplicationModal);
    worker->show();
}
void MainWindow::slotUpdateWorker() {}
void MainWindow::slotDeleteWorker() {}

void MainWindow::slotAddUser()
{
    User * user = new User(0);
    user->setGeometry(
        QStyle::alignedRect(
            Qt::LeftToRight,
            Qt::AlignCenter,
            user->size(),
            qApp->desktop()->availableGeometry()
        ));
    user->setWindowModality(Qt::ApplicationModal);
    user->show();
}

void MainWindow::slotUpdateUser() {}
void MainWindow::slotDeleteUser() {}

void MainWindow::slotExit()
{
    close();
}
